package com.techsoul.common.core.pojo.entity;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * Entity基类
 *
 * @author liuen
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class DataEntity extends BaseEntity {

    /**
     * ID
     */
    protected String id;

    /**
     * 备注
     */
    protected String remark;

    /**
     * 是否有效
     */
    protected String isValid;

    /**
     * 创建人
     */
    protected String createBy;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    protected Date createTime;

    /**
     * 更新人
     */
    protected String updateBy;

    /**
     * 更新时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    protected Date updateTime;

    @Override
    public void preInsert(String userId) {
        this.createBy = userId;
        this.updateBy = userId;
        this.createTime = new Date();
        this.updateTime = createTime;

    }

    @Override
    public void preUpdate(String userId) {
        this.updateBy = userId;
        this.updateTime = new Date();
    }

}
